package model.inventory;
// Generated Oct 27, 2012 8:43:23 AM by Hibernate Tools 3.2.1.GA


import java.util.Collections;
import java.util.Date;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import utility.typeSafe.ItemPerfoma;

/**
 * MstItem generated by hbm2java
 */
@Entity
@Table(name="mst_item", schema="inventory")
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
public class Item  implements java.io.Serializable {

    private int id;
    private Principal principal;
    private Dept dept;
    private Packaging packaging;
    private Unit unit;
    private String plu;
    private String barcode;
    private String barcode2;
    private String nama;
    private String struk;
    private String divOrder;
    private Integer stokMin;
    private Integer stokMax;
    private Integer stokX;
    private Boolean bkp;
    private Boolean halal;
    private Boolean konsinyasi;
    private String performa;
    private Date disabledDate;
    private Date updatedDate;
    private Date insertedDate;
    private String supplierName;
    private List<Item> children;
    
    
    public Item() {
        this.stokMin=0;
        this.stokMax=0;
        this.stokX=0;
        this.bkp=true;
        this.halal=true;
        this.konsinyasi=false;
        this.performa= ItemPerfoma.FAST_MOVING.toString();
        this.principal = new Principal();
        this.dept = new Dept();
        this.unit = new Unit();
        this.packaging = new Packaging();
    }
	
    public Item(int id) {
        this.id = id;
    }

    public Item(int id, String plu, String nama, String divOrder, String supplierName, List<Item> children) {
        this.id = id;
        this.plu = plu;
        this.nama = nama;
        this.divOrder = divOrder;
        this.children = children;
        this.supplierName = supplierName;
        if (this.children == null) { this.children = Collections.emptyList(); }
    }
    
    @Id 
    @SequenceGenerator(name="item_seq", sequenceName="inventory.mst_item_id_seq", allocationSize=1)
    @GeneratedValue(strategy= GenerationType.SEQUENCE, generator="item_seq")
    @Column(name="id", unique=true, nullable=false)
    public int getId() {
        return this.id;
    }
    
    public void setId(int id) {
        this.id = id;
    }
    
    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="principal_id")
    public Principal getPrincipal() {
        return this.principal;
    }
    
    public void setPrincipal(Principal principal) {
        this.principal = principal;
    }
    
    //fetch=FetchType.EAGER
    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="dept_id")
    public Dept getDept() {
        return this.dept;
    }
    
    public void setDept(Dept dept) {
        this.dept = dept;
    }
    //fetch=FetchType.EAGER
    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="package_id")
    public Packaging getPackaging() {
        return this.packaging;
    }
    
    public void setPackaging(Packaging packaging) {
        this.packaging = packaging;
    }
    
    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="unit_id")
    public Unit getUnit() {
        return this.unit;
    }
    
    public void setUnit(Unit unit) {
        this.unit = unit;
    }
    
    @Column(name="plu", length=20)
    public String getPlu() {
        return this.plu;
    }
    
    public void setPlu(String plu) {
        this.plu = plu;
    }
    
    @Column(name="barcode", length=15)
    public String getBarcode() {
        return this.barcode;
    }
    
    public void setBarcode(String barcode) {
        this.barcode = barcode;
    }
    
    @Column(name="barcode2", length=15)
    public String getBarcode2() {
        return this.barcode2;
    }
    
    public void setBarcode2(String barcode2) {
        this.barcode2 = barcode2;
    }
    
    @Column(name="nama", length=100)
    public String getNama() {
        return this.nama;
    }
    
    public void setNama(String nama) {
        this.nama = nama;
    }
    
    @Column(name="struk", length=40)
    public String getStruk() {
        return this.struk;
    }
    
    public void setStruk(String struk) {
        this.struk = struk;
    }
    
    @Column(name="div_order", length=4)
    public String getDivOrder() {
        return this.divOrder;
    }
    
    public void setDivOrder(String divOrder) {
        this.divOrder = divOrder;
    }
    
    @Column(name="stok_min")
    public Integer getStokMin() {
        return this.stokMin;
    }
    
    public void setStokMin(Integer stokMin) {
        this.stokMin = stokMin;
    }
    
    @Column(name="stok_max")
    public Integer getStokMax() {
        return this.stokMax;
    }
    
    public void setStokMax(Integer stokMax) {
        this.stokMax = stokMax;
    }
    
    @Column(name="stok_x")
    public Integer getStokX() {
        return this.stokX;
    }
    
    public void setStokX(Integer stokX) {
        this.stokX = stokX;
    }
    
    @Column(name="bkp")
    public Boolean getBkp() {
        return this.bkp;
    }
    
    public void setBkp(Boolean bkp) {
        this.bkp = bkp;
    }
    
    @Column(name="halal")
    public Boolean getHalal() {
        return this.halal;
    }
    
    public void setHalal(Boolean halal) {
        this.halal = halal;
    }
    
    @Column(name="konsinyasi")
    public Boolean getKonsinyasi() {
        return this.konsinyasi;
    }
    
    public void setKonsinyasi(Boolean konsinyasi) {
        this.konsinyasi = konsinyasi;
    }
    
    @Column(name="performa", length=1)
    public String getPerforma() {
        return this.performa;
    }
    
    public void setPerforma(String performa) {
        this.performa = performa;
    }
    
    @Temporal(TemporalType.DATE)
    @Column(name="disabled_date", length=13)
    public Date getDisabledDate() {
        return this.disabledDate;
    }
    
    public void setDisabledDate(Date disabledDate) {
        this.disabledDate = disabledDate;
    }
    @Temporal(TemporalType.DATE)
    @Column(name="updated_date", length=13)
    public Date getUpdatedDate() {
        return this.updatedDate;
    }
    
    public void setUpdatedDate(Date updatedDate) {
        this.updatedDate = updatedDate;
    }
    
    @Temporal(TemporalType.DATE)
    @Column(name="inserted_date", length=13)
    public Date getInsertedDate() {
        return this.insertedDate;
    }
    
    public void setInsertedDate(Date insertedDate) {
        this.insertedDate = insertedDate;
    }

    @Transient
    public List<Item> getChildren() {
        return children;
    }

    public void setChildren(List<Item> children) {
        this.children = children;
    }

    @Transient
    public String getSupplierName() {
        return supplierName;
    }

    public void setSupplierName(String supplierName) {
        this.supplierName = supplierName;
    }

    @Override
     public String toString() {
        return this.getPlu();
    } 

}


